/*
 * Copyright:  2018 smarabbit studio.
 *
 *  Licensed under the Confluent Community License; you may not use this file
 *  except in compliance with the License.  You may obtain a copy of the License at
 *
 *  http://www.confluent.io/confluent-community-license
 *
 *  Unless required by applicable law or agreed to in writing, software
 *  distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
 *  WARRANTIES OF ANY KIND, either express or implied.  See the License for the
 *  specific language governing permissions and limitations under the License.
 *
 *  @作   者： 黄开晖 (117227773@qq.com)
 *  @日   期:  2021年5月23日
 */
package com.massyframework.beanskin.util.version;

/**
 * {@link JDKVersion} 提供当前运行环境的jdk版本
 */
abstract class JDKVersion {

    /**
     * 版本号，8...17 任意一个
     */
    public static int VERSION;
    static {
        String specVersion = System.getProperty("java.version");
        if (specVersion.startsWith("1.8"))
            VERSION = 8;
        else if (specVersion.startsWith("9."))
            VERSION =9;
        else if (specVersion.startsWith("10."))
            VERSION =10;
        else if (specVersion.startsWith("11."))
            VERSION =11;
        else if (specVersion.startsWith("12."))
            VERSION =12;
        else if (specVersion.startsWith("13."))
            VERSION =13;
        else if (specVersion.startsWith("14."))
            VERSION =14;
        else if (specVersion.startsWith("15."))
            VERSION =15;
        else if (specVersion.startsWith("16."))
            VERSION =16;
        else if (specVersion.startsWith("17."))
            VERSION =17;
        // maybe someday...
    }

    /**
     * 版本
     * @return {@link int}
     */
    public static int getVersion(){
        return VERSION;
    }


    /**
     * 判断是否运行再JDK9以上版本
     * @return {@link boolean}, 返回<code>true</code>表示是，否则返回<code>false</code>
     */
    public static boolean isAtLeastJava9(){
        return VERSION >= 9;
    }
}
